Conversation
tests are still waiting
yurii-litvinov
left a comment
There was a problem hiding this comment.
В целом так, но как-то уж очень нетехнично.
hw6Game/hw6Game/Game.cs
Outdated
| coordinates = map.GetPlayerCoordinates(); | ||
| switch (step) | ||
| { | ||
| case "left": |
There was a problem hiding this comment.
Мм. Для этого и придумали enum-ы. Хотя, честно говоря, для этого придумали лямбды, чтобы switch-и тут не писать :) Подумайте, как это написать более красиво
|
|
||
| namespace hw6Game | ||
| { | ||
| public class EventLoop |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
| public event EventHandler<EventArgs> LeftHandler = (sender, args) => { }; | ||
| public event EventHandler<EventArgs> RightHandler = (sender, args) => { }; | ||
| public event EventHandler<EventArgs> UpHandler = (sender, args) => { }; | ||
| public event EventHandler<EventArgs> DownHandler = (sender, args) => { }; |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
hw6Game/hw6Game.Test/MoveTest.cs
Outdated
| [SetUp] | ||
| public void Setup() | ||
| { | ||
| eventLoop = new EventLoop(); |
There was a problem hiding this comment.
Что-то он нигде не используется
hw6Game/hw6Game/Map.cs
Outdated
| public int y; | ||
| } | ||
|
|
||
| static private string[] mapPic; |
There was a problem hiding this comment.
А почему он static?
hw6Game/hw6Game/Map.cs
Outdated
| { | ||
| public class Map | ||
| { | ||
| private struct PlayerCoordination |
There was a problem hiding this comment.
"Координация", не "Координаты"?
|
|
||
| public event EventHandler<EventArgs> DownHandler = (sender, args) => { }; | ||
|
|
||
| public void Run() |
There was a problem hiding this comment.
Комментарии к методам и даже событиям тоже нужны, но ладно
hw6Game/hw6Game/Game.cs
Outdated
|
|
||
| public void OnLeft(object sender, EventArgs args) | ||
| { | ||
| Move("left"); |
There was a problem hiding this comment.
Ну да, а если тут или в Move опечататься, то не будет работать, и компилятор не поругается. Варианты решения проблемы:
а) enum-ы,
б) лямбда-функции
Реализуйте что-то из этого :)
hw6Game/hw6Game/Map.cs
Outdated
|
|
||
| private string[] mapPic; | ||
|
|
||
| static private PlayerCoordinates player = new PlayerCoordinates(); |
There was a problem hiding this comment.
Просто new(), зачем имя типа дважды писать
hw6Game/hw6Game/Map.cs
Outdated
| return false; | ||
| } | ||
| player.y -= 1; | ||
| return true; |
There was a problem hiding this comment.
Ну тут точно стоило передавать в Move функцию, которая бы возвращала изменённую координату, чтобы четыре раза одно и то же не писать
yurii-litvinov
left a comment
There was a problem hiding this comment.
Всё равно неаккуратно. Неаккуратных программистов вся команда ненавидит :)
| left, | ||
| right, | ||
| up, | ||
| down |
There was a problem hiding this comment.
Элементы enum-а в .NET пишутся с заглавной
| public void OnLeft(object sender, EventArgs args) | ||
| { | ||
| Move(Moves.left); | ||
| } | ||
|
|
||
| public void OnRight(object sender, EventArgs args) | ||
| { | ||
| Move(Moves.right); | ||
| } | ||
|
|
||
| public void OnDown(object sender, EventArgs args) | ||
| { | ||
| Move(Moves.down); | ||
| } | ||
|
|
||
| public void OnUp(object sender, EventArgs args) | ||
| { | ||
| Move(Moves.up); | ||
| } |
There was a problem hiding this comment.
Однострочники пишутся через =>
|
|
||
| private bool CheckMove((int x, int y) coord) | ||
| { | ||
| if (mapPic[coord.y][coord.x ] != ' ' && mapPic[coord.y][coord.x] != '@') |
There was a problem hiding this comment.
| if (mapPic[coord.y][coord.x ] != ' ' && mapPic[coord.y][coord.x] != '@') | |
| if (mapPic[coord.y][coord.x] != ' ' && mapPic[coord.y][coord.x] != '@') |
| return false; | ||
| } | ||
| player.x = coord.x; | ||
| player.y =coord.y; |
There was a problem hiding this comment.
| player.y =coord.y; | |
| player.y = coord.y; |
| default: | ||
| return false; | ||
| } | ||
| } |
No description provided.